SRC=src
BIN=bin
LIB=lib
SLIB=so
INTER=intermediate
INCLUDES = -Iinclude

LLIB = -Llib
LIBS = -lglad -lglfw3dll -lopengl32 -static-libgcc -static-libstdc++

CXXFLAGS = -Wall -std=c++11 $(INCLUDES) $(LLIB) $(LIBS)
CC = gcc
CXX = g++
AR = ar
TEX = textures

SOURCES = $(wildcard $(SRC)/*.cpp)

all-win: prebuild-win build-win copy-win 
	del /F /S /Q $(INTER)\*

prebuild-win:
	if not exist $(INTER) mkdir $(INTER)
	if not exist $(SLIB) mkdir $(SLIB)
	if not exist $(LIB) mkdir $(LIB)
	if not exist $(BIN)\$(TEX) mkdir $(BIN)\$(TEX)

#build-win:	0.HelloWindow.exe 1.HelloTriangle.exe 2.Shaders.exe \
			3.Textures.exe 4.Transform.exe 5.CoordinateSys.exe \
			6.Camera.exe 7.Colors.exe 8.BasicLighting.exe 9.Materials.exe \
			10.LightingMap.exe 11.LightCasters.exe 12.MultipleLights.exe
build-win: 12.MultipleLights.exe

copy-win: 
	copy .\$(SLIB)\*.dll .\$(BIN)
	copy .\$(SRC)\shaders\* .\$(BIN)
	copy .\$(TEX)\* .\$(BIN)\$(TEX)

0.HelloWindow.exe: glad.a
	$(CXX) -g ./$(SRC)/0.HelloWindow/*.cpp -o ./bin/$@ $(CXXFLAGS)

1.HelloTriangle.exe: glad.a
	$(CXX) -g ./$(SRC)/1.HelloTriangle/*.cpp -o ./bin/$@ $(CXXFLAGS)

2.Shaders.exe: glad.a
	$(CXX) -g ./$(SRC)/2.Shaders/*.cpp -o ./bin/$@ $(CXXFLAGS)

3.Textures.exe: glad.a
	$(CXX) -g ./$(SRC)/3.Textures/*.cpp -o ./bin/$@ $(CXXFLAGS)

4.Transform.exe: glad.a
	$(CXX) -g ./$(SRC)/4.Transform/*.cpp -o ./bin/$@ $(CXXFLAGS)

5.CoordinateSys.exe: glad.a
	$(CXX) -g ./$(SRC)/5.CoordinateSys/*.cpp -o ./bin/$@ $(CXXFLAGS)

6.Camera.exe: glad.a
	$(CXX) -g ./$(SRC)/6.Camera/*.cpp -o ./bin/$@ $(CXXFLAGS)

7.Colors.exe: glad.a
	$(CXX) -g ./$(SRC)/7.Colors/*.cpp -o ./bin/$@ $(CXXFLAGS)

8.BasicLighting.exe: glad.a
	$(CXX) -g ./$(SRC)/8.BasicLighting/*.cpp -o ./bin/$@ $(CXXFLAGS)

9.Materials.exe: glad.a
	$(CXX) -g ./$(SRC)/9.Materials/*.cpp -o ./bin/$@ $(CXXFLAGS)

10.LightingMap.exe: glad.a
	$(CXX) -g ./$(SRC)/10.LightingMap/*.cpp -o ./bin/$@ $(CXXFLAGS)

11.LightCasters.exe: glad.a
	$(CXX) -g ./$(SRC)/11.LightCasters/*.cpp -o ./bin/$@ $(CXXFLAGS)

12.MultipleLights.exe: glad.a
	$(CXX) -g ./$(SRC)/12.MultipleLights/*.cpp -o ./bin/$@ $(CXXFLAGS)

glad.a:
	$(CC) -c $(SRC)/glad/glad.c -o $(INTER)/glad.o $(INCLUDES)
	$(AR) rcs $(LIB)/libglad.a $(INTER)/glad.o